<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>接口文档</title>
    <link rel="shortcut icon" href="http://www.yunjiaowu.cn/images/yunjiaowu.ico" type="image/x-icon">
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>

</head>
<body>
<div>
    <li style="display:inline-block;">JFinal-API Beta V1</li>
    <li style="display:inline-block;"><a target="_blank" href="https://www.jfinal.com/user/99521">JFinal社区</a></li>
    <li style="display:inline-block;"><a target="_blank" href="http://www.yunjiaowu.org">云教务赞助</a></li>
    <li style="display:inline-block;"><a target="_blank" href="https://jq.qq.com/?_wv=1027&k=5MKAovD">Q群263104005</a></li>
</div>
<hr>
<h2>接口文档</h2>
<div id="doc">
    <div class="operationDiv" id="operationDiv">
        <span>提示：Ctrl + F 可搜索</span>
        <button @click="report()">请求报告</button>
        <button @click="test()">测一下</button>
    </div>
    <div>
        <ol style="width:35%;float:left;overflow:auto;">
            <li v-for="val in allActionKeys">
                <a @click="details(val)" :href="'#'+ val.doc">{{ val.doc }}</a><br/>
                <a @click="test(val.actionKey)" :href="'#'+ val.doc">{{ val.actionKey }}</a>
            </li>
        </ol>
        <div style="width:60%;float:right;overflow:auto;" v-html="content"></div>
    </div>
</div>
<script type="text/javascript">
    window.onload = function() {
        var allActionKeys = [];
        var vm = new Vue({
            el : '#doc',
            data : {
                content : '请先点击某接口url',
                allActionKeys : allActionKeys,
                showActionKey : null,
                url : '/mini/app/api/allActionKeys'
            },
            methods : {
                details: function(val){
                    vm.showActionKey = val;
                    this.$http.post(vm.url + '/details', val).then(function(res) {
                        console.log(vm.url, "的MD文档:", res);
                        vm.content = res.body.data;
                    }, function(res) {
                        console.log(res.status);
                    });
                },
                report: function () {
                    window.open("/report");
                },
                test: function (actionKey) {
                    if (!actionKey) {
                        actionKey = vm.showActionKey.actionKey;
                    }
                    window.open("/test?actionKey=" + actionKey);
                }
            }
        });
        //发送 post 请求
        vm.$http.post(vm.url).then(function(res) {
            console.log(res);
            var d = res.body.data;
            for( i in d){
                allActionKeys.push(d[i]);
            }
        }, function(res) {
            console.log(res);
        });
    }

</script>
</body>
</html>